import { getToken } from '@/utils/auth'
// import Cookies from 'js-cookie'
const mixin = {
  data () {
    return {
      meterageFlag: {
        '0': '是',
        '1': '否'
      },
      statusSystem: [//上下架状态
        {
          label: "上架中",
          value: '0',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "下架中",
          value: '1',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
      ],
      statusFlag: [//基值状态
        {
          label: "启用中",
          value: '0',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "禁用中",
          value: '1',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
      ],
      statusDevicedist: [
        {
          label: "正常",
          value: '0',
          classColor: '#409EFF',
          icon: 'el-icon-success',
          raw: {
            listClass: "primary",
          }
        },
        {
          label: "带病运行",
          value: '1',
          classColor: '#9400D3',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },
        {
          label: "检修中",
          value: '2',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },
        {
          label: "故障",
          value: '3',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
        {
          label: "维修工单 - 维修中",
          value: '4',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },
        {
          label: "维修工单 - 报废",
          value: '5',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        }
      ],
      statusAllocation: [//调拨审核状态
        {
          label: "审核中",
          value: '0',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },
        {
          label: "已通过",
          value: '1',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "已驳回",
          value: '2',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
        {
          label: "待提交",
          value: '3',
          classColor: '#409EFF',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },
        {
          label: "已撤销",
          value: '4',
          classColor: '#DCDFE6',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
      ],
      statusHelp: [//帮助状态
        {
          label: "已发布",
          value: '0',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "未生效",
          value: '1',
          classColor: '#909399',
          icon: 'el-icon-info',
          raw: {
            listClass: "info",
          }
        },
      ],
      statusPlan: [//计划状态
        {
          label: "未生成",
          value: '0',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
        {
          label: "待执行",
          value: '1',
          classColor: '#909399',
          icon: 'el-icon-info',
          raw: {
            listClass: "info",
          }
        }, {
          label: "执行中",
          value: '2',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        }, {
          label: "已完成",
          value: '3',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
      ],
      statusAudit: [//计划状态
        {
          label: "待审核",
          value: '0',
          classColor: '#909399',
          icon: 'el-icon-info',
          raw: {
            listClass: "info",
          }
        }, {
          label: "审核中",
          value: '1',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        }, {
          label: "已通过",
          value: '2',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "已驳回",
          value: '3',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
      ],
      acceptanceStatus: [//验收状态
        {
          label: "待验收",
          value: '0',
          classColor: '#909399',
          icon: 'el-icon-info',
          raw: {
            listClass: "info",
          }
        }, {
          label: "已通过",
          value: '1',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "未通过",
          value: '2',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
      ],
      upkeepStatus: [//保养状态
        {
          label: "未开始",
          value: '0',
          classColor: '#909399',
          icon: 'el-icon-info',
          raw: {
            listClass: "info",
          }
        },
        {
          label: "待执行",
          value: '1',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },
        {
          label: "重新保养",
          value: '2',
          classColor: '#409EFF',
          icon: 'el-icon-success',
          raw: {
            listClass: "primary",
          }
        },

        {
          label: "已完成",
          value: '3',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "已作废",
          value: '4',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        }
      ],
      repairStatus: [//维修状态
        {
          label: "待执行",
          value: '1',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },
        {
          label: "维修中",
          value: '2',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },

        {
          label: "已解决",
          value: '3',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "故障",
          value: '4',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        }
      ],
      inspectionStatus: [//巡检状态
        {
          label: "已完成",
          value: '0',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "未完成",
          value: '1',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        }
      ],
      inspectionStatusTwo: [//巡检状态
        {
          label: "未完成",
          value: '0',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
        {
          label: "已完成",
          value: '1',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        }
      ],
      MessageStatus: [//消息状态
        {
          label: "成功",
          value: '0',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "失败",
          value: '1',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        }
      ],
      ReadStatus: [//读取状态
        {
          label: "已读",
          value: '0',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "未读",
          value: '1',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        }
      ],
      InventoryStatus: [//入库状态
        {
          label: "待入库",
          value: '0',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "已入库",
          value: '1',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "danger",
          }
        }
      ],
      TheDeliveryStatus: [//出库状态
        {
          label: "待出库",
          value: '0',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "已出库",
          value: '1',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "danger",
          }
        }
      ],
      SparePartsAndConsumables: [
        {
          label: "耗材",
          value: '0',
          classColor: '#E6A23C',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "备件",
          value: '1',
          classColor: '#67C23A',
          raw: {
            listClass: "warning",
          }
        }
      ],
      statusInspection: [//巡检任务状态
        {
          label: "待完成",
          value: '0',
          classColor: '#909399',
          icon: 'el-icon-info',
          raw: {
            listClass: "info",
          }
        }, {
          label: "延期中",
          value: '1',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        }, {
          label: "已完成",
          value: '2',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "延期完成",
          value: '3',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "已失效",
          value: '4',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
      ],
      returnStatus: [//归还状态
        {
          label: "外借中",
          value: '0',
          classColor: '#E6A23C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        }, {
          label: "延期中",
          value: '1',
          classColor: '#F56C6C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        }, {
          label: "已归还",
          value: '2',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "延期归还",
          value: '3',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        },
        {
          label: "已失效",
          value: '4',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        },
      ],
      abnormalStatus: [
        {
          label: "无异常",
          value: '0',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        }, {
          label: "有异常",
          value: '1',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        }, {
          label: "处理中",
          value: '2',
          classColor: '#F56C6C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        }, {
          label: "已处理",
          value: '3',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        }
      ],
      remindStatus: [
        {
          label: "未响应",
          value: '0',
          classColor: '#F56C6C',
          icon: 'el-icon-warning',
          raw: {
            listClass: "warning",
          }
        },
        {
          label: "已响应",
          value: '1',
          classColor: '#67C23A',
          icon: 'el-icon-success',
          raw: {
            listClass: "success",
          }
        }, {
          label: "已失效",
          value: '2',
          classColor: '#F56C6C',
          icon: 'el-icon-error',
          raw: {
            listClass: "danger",
          }
        }
      ],
    }
  },
  computed: {
    // api_header_url () { // 拼接图片时使用
    //   return process.env.VUE_APP_IMG_SERVER_URL
    // },
    action_url () { // 文件上传时使用
      return process.env.VUE_APP_BASE_API + '/file/upload'
    },
    // admin_roles () { //当前角色的权限
    //   return this.$store.state.user.roles[0]
    // }
    header_url () {
      return {
        Authorization: 'Bearer ' + getToken()
      }
    }
  },
  created () {
    // this.dictlist();
  },
  methods: {
    // async dictlist () {
    //   let data = await getdatalist({ dictType: 'base_unit' })
    //   this.dictListData = data
    // }
    // 米转换km
    kmUnit (m) {
      var v;
      if (typeof m === 'number' && !isNaN(m)) {
        if (m >= 1000) {
          v = (m / 1000).toFixed(2) + '公里'
        } else {
          v = m + '米'
        }
      } else {
        v = '0米'
      }
      return v;
    }
  },
  filters: {
    ellipsis (value, num) {
      if (!value) return "";
      if (value.length > num) {
        return value.slice(0, num) + "...";
      }
      return value;
    },
    formatDate (cellValue) {
      if (cellValue == null || cellValue == "") return "";
      var date = new Date(cellValue)
      var year = date.getFullYear()
      var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
      var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
      var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
      var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
      var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
      return year + '-' + month + '-' + day
      //  + ' ' + hours + ':' + minutes + ':' + seconds
    },
    // 米转换km
    kmUnit (m) {
      var v;
      if (typeof m === 'number' && !isNaN(m)) {
        if (m >= 1000) {
          v = (m / 1000).toFixed(2) + '公里'
        } else {
          v = m + '米'
        }
      } else {
        v = '0米'
      }
      return v;
    }
  },
}
export default mixin
